/********************************************************/
/*	Author:		gong_libin			*/
/*	Date:		2017_11_01			*/
/*	File:		CmRedisTest.cpp			*/
/********************************************************/

#include <vector>
#include "CmRedis.h"

int main(int argc, char* argv[])
{
	CMSTRING_C CTmp;
	char szTmp[CM_BUFFER] = {'\0'};
	CMSTRING_C CAddr = "127.0.0.1:6379";
	CMSTRING_C CLst = "CmRedis_List_key";
	CMSTRING_C CKey = "CmRedis_String_key";
	CMSTRING_C CVal = "CmRedis_String_val";

	CCmRedis CRedis(CAddr);

	// string
	CRedis.set(CKey, CVal);
	if (true == CRedis.get(CKey, &CTmp)) {
		CM_PRINT("%s: %s\n", CKey.c_str(), CTmp.c_str());
	}

	for (int iIdx = 0; iIdx < 10; iIdx ++) {
		sprintf(szTmp, "CmRedis_List_val_%d", iIdx);
		CRedis.rpush(CLst, CMSTRING_C(szTmp));
	}

	// list
	while (0 != CRedis.llen(CLst)) {
		if (true == CRedis.lpop(CLst, &CVal)) {
			CM_PRINT("%s: %s\n", CLst.c_str(), CVal.c_str());
		}
	}

	return CM_SUCCESS;
}
